﻿using System;
using System.Web.UI;
using Test.DAL;
using Test.IDAL;

namespace Test_Stu
{
    public partial class StuInfoAdd : System.Web.UI.Page
    {
        IStuInfoDAL bll = new StuInfoDAL();
        protected void Page_Load(object sender, EventArgs e)
        {
            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var name = TextBox1.Value;
            var cont = TextBox2.Text;
            int id = Convert.ToInt32(TextBox3.Text);
            Test.Model.StuInfo info = new  Test.Model.StuInfo()
            {
                Name = name,
                content = cont,
                Cid = id
            };
            var result = bll.Insert(info);
            if (result.States && result.Data > 0)
            {
                Response.Write("<script>alert('添加成功');location='StuInfo.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('" + result.message + "')</script>");
            }
        }
    }
}